<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use app\portal\model\PortalCategoryModel;

class ListController extends HomeBaseController
{
    public function index()
    {
		
       
    	$id  = $this->request->param('id', 0, 'intval');
    	//exit($id);
        $portalCategoryModel = new PortalCategoryModel();

        $category = $portalCategoryModel->where('id', $id)->where('status', 1)->find()->toArray();;
       
        $this->assign('category', $category);

        $listTpl = empty($category['list_tpl']) ? 'list' : $category['list_tpl'];
     
        //取分类
       // print_r($category); die();
      // exit($category['parent_id']);
      if($category['parent_id']==0){
      	$category_list = $portalCategoryModel->where('parent_id', $id)->where('status', 1)->select()->toArray();
      	//print_r($category_list); die();
      }else{
      	//$parent_$category
      	$category_list = $portalCategoryModel->where('parent_id', $category['parent_id'])->where('status', 1)->select()->toArray();
      }
     
      $this->assign('category_list', $category_list);
        
        return $this->fetch('/' . $listTpl);
    }

}
